define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'member/index',
                    add_url: 'member/add',
                    edit_url: 'member/edit',
                    del_url: 'member/del',
                    multi_url: 'member/multi',
                    table: 'member',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_name', title: __('User_name')},
                        {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'wechat', title: __('Wechat')},
                        {field: 'wechat_image', title: __('Wechat_image'), formatter: Table.api.formatter.image},
                        {field: 'avatar', title: __('Avatar')},
                        {field: 'images', title: __('Images'), formatter: Table.api.formatter.images},
                        {field: 'gender', title: __('Gender')},
                        {field: 'birth_province', title: __('Birth_province')},
                        {field: 'live_province', title: __('Live_province')},
                        {field: 'id_image', title: __('Id_image'), formatter: Table.api.formatter.image},
                        {field: 'live_district', title: __('Live_district')},
                        {field: 'height', title: __('Height')},
                        {field: 'weight', title: __('Weight')},
                        {field: 'education_id', title: __('Education_id')},
                        {field: 'income_id', title: __('Income_id')},
                        {field: 'zodiac_id', title: __('Zodiac_id')},
                        {field: 'marriage_id', title: __('Marriage_id')},
                        {field: 'car_id', title: __('Car_id')},
                        {field: 'house_id', title: __('House_id')},
                        {field: 'worker', title: __('Worker')},
                        {field: 'authen_status', title: __('Authen_status'), searchList: {"0":__('Authen_status 0'),"1":__('Authen_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'rec_status', title: __('Rec_status'), searchList: {"0":__('Rec_status 0'),"1":__('Rec_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'rec_start_time', title: __('Rec_start_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'rec_end_time', title: __('Rec_end_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'up_num', title: __('Up_num')},
                        {field: 'tags_ids', title: __('Tags_ids')},
                        {field: 'last_login_time', title: __('Last_login_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});